package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author MissChen
 * @date 2024年04月23日 16:19
 */
@WebServlet("/test/*")
// @WebServlet("/*")
public class TestServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();

        //对于/xxx/*,该方式的取值就是/xxx
        // 省略表示任意请求都能访问到该Servlet,/*一般不建议使用
        //  servletPath只能获取到/xxx的值
        String servletPath = request.getServletPath();
        System.out.println(servletPath);

        out.println("<h1 style='color:green;'>hello,i am  coming</h1>");
    }
}
